// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.SearchApplication;

public sealed partial class PutSearchApplicationRequestParameters : RequestParameters
{
	/// <summary>
	/// <para>
	/// If <c>true</c>, this request cannot replace or update existing Search Applications.
	/// </para>
	/// </summary>
	public bool? Create { get => Q<bool?>("create"); set => Q("create", value); }
}

/// <summary>
/// <para>
/// Create or update a search application.
/// </para>
/// </summary>
public sealed partial class PutSearchApplicationRequest : PlainRequest<PutSearchApplicationRequestParameters>, ISelfSerializable
{
	public PutSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationPut;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "search_application.put";

	/// <summary>
	/// <para>
	/// If <c>true</c>, this request cannot replace or update existing Search Applications.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public bool? Create { get => Q<bool?>("create"); set => Q("create", value); }
	[JsonIgnore]
	public Elastic.Clients.Elasticsearch.SearchApplication.SearchApplication SearchApplication { get; set; }

	void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		JsonSerializer.Serialize(writer, SearchApplication, options);
	}
}

/// <summary>
/// <para>
/// Create or update a search application.
/// </para>
/// </summary>
public sealed partial class PutSearchApplicationRequestDescriptor : RequestDescriptor<PutSearchApplicationRequestDescriptor, PutSearchApplicationRequestParameters>
{
	internal PutSearchApplicationRequestDescriptor(Action<PutSearchApplicationRequestDescriptor> configure) => configure.Invoke(this);
	public PutSearchApplicationRequestDescriptor(Elastic.Clients.Elasticsearch.SearchApplication.SearchApplication searchApplication, Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name)) => SearchApplicationValue = searchApplication;

	internal override ApiUrls ApiUrls => ApiUrlLookup.SearchApplicationPut;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "search_application.put";

	public PutSearchApplicationRequestDescriptor Create(bool? create = true) => Qs("create", create);

	public PutSearchApplicationRequestDescriptor Name(Elastic.Clients.Elasticsearch.Name name)
	{
		RouteValues.Required("name", name);
		return Self;
	}

	private Elastic.Clients.Elasticsearch.SearchApplication.SearchApplication SearchApplicationValue { get; set; }
	private Elastic.Clients.Elasticsearch.SearchApplication.SearchApplicationDescriptor SearchApplicationDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.SearchApplication.SearchApplicationDescriptor> SearchApplicationDescriptorAction { get; set; }

	public PutSearchApplicationRequestDescriptor SearchApplication(Elastic.Clients.Elasticsearch.SearchApplication.SearchApplication searchApplication)
	{
		SearchApplicationDescriptor = null;
		SearchApplicationDescriptorAction = null;
		SearchApplicationValue = searchApplication;
		return Self;
	}

	public PutSearchApplicationRequestDescriptor SearchApplication(Elastic.Clients.Elasticsearch.SearchApplication.SearchApplicationDescriptor descriptor)
	{
		SearchApplicationValue = null;
		SearchApplicationDescriptorAction = null;
		SearchApplicationDescriptor = descriptor;
		return Self;
	}

	public PutSearchApplicationRequestDescriptor SearchApplication(Action<Elastic.Clients.Elasticsearch.SearchApplication.SearchApplicationDescriptor> configure)
	{
		SearchApplicationValue = null;
		SearchApplicationDescriptor = null;
		SearchApplicationDescriptorAction = configure;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		JsonSerializer.Serialize(writer, SearchApplicationValue, options);
	}
}